package firbi.base;

import java.util.GregorianCalendar;

import android.content.Intent;
import android.os.Bundle;
import android.provider.Contacts;
import android.test.ActivityUnitTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class StopViewUnitTest extends ActivityUnitTestCase<StopView> {
	Intent mStartIntent;
	//StopView mStopView;
	public StopViewUnitTest() {
		super(StopView.class);
		// TODO Auto-generated constructor stub
	}
	
	@Override
    protected void setUp() throws Exception {
        super.setUp();
        mStartIntent = new Intent(Intent.ACTION_MAIN);
    }
    @Override
    protected void tearDown() throws Exception {
    	super.tearDown();
    }
	
	@SmallTest
	public void testTimeDiff(){
		StopView mStopView = startActivity(mStartIntent, null, null);
		GregorianCalendar cal1 = new GregorianCalendar(2009,5,18,11,5,0);
		GregorianCalendar cal2 = new GregorianCalendar(2009,5,18,11,55,0);
		GregorianCalendar cal3 = new GregorianCalendar(2009,5,18,12,5,0);
		GregorianCalendar cal4 = new GregorianCalendar(2009,5,18,13,5,0);
		GregorianCalendar cal5 = new GregorianCalendar(2009,5,18,23,5,0);
		GregorianCalendar cal6 = new GregorianCalendar(2009,5,19,0,5,0);
		//cal1 < cal2 => negative of the different
		assertEquals(mStopView.timeDiff(cal1, cal2), -50);
		//cal2 > cal1 => positive of the different 
		assertEquals(mStopView.timeDiff(cal2, cal1), 50);
		//cal2 < cal4 => -70
		assertEquals(mStopView.timeDiff(cal2, cal4), -70);
		//cal5 < cal6 => -60
		assertEquals(mStopView.timeDiff(cal5, cal6), -60);
		//cal5 > cal6 => 60
		assertEquals(mStopView.timeDiff(cal6, cal5), 60);
		assertEquals(55, mStopView.timeDiff(new GregorianCalendar(2009,5,18,1,0,0), new GregorianCalendar(2009,5,18,0,5,0)));
	}
}
